unit Class_MovRulX;

interface
uses
  Classes,SysUtils,Uni,UniEngine;

type
  TMovRulX=class(TUniEngine)
  public
    RULXIDEX: Integer;                    
    RULXTEXT: string;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    function  GetNextIdex:Integer;overload;
    function  GetNextIdex(AUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(AUniConnection:TUniConnection):Boolean;override;
  public
    destructor  Destroy; override;
    constructor Create;  
  public
    class function  ReadDS(AUniQuery:TUniQuery):TUniEngine;override;
    class function  CopyIt(AMovRulX:TMovRulX):TMovRulX;overload;        
    class procedure CopyIt(AMovRulX:TMovRulX;var Result:TMovRulX);overload;       
  end;

implementation

{ TMovRulX }
procedure TMovRulX.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('RULX_IDEX').Value := RULXIDEX;
        ParamByName('RULX_TEXT').Value := RULXTEXT; 
      end;
      otEdit:
      begin
        ParamByName('RULX_IDEX').Value := RULXIDEX;
        ParamByName('RULX_TEXT').Value := RULXTEXT; 
      end;  
      otDelt:
      begin
        ParamByName('RULX_IDEX').Value := RULXIDEX;
 
      end;  
    end;
  end;
end;

function TMovRulX.CheckExist(AUniConnection: TUniConnection): Boolean;
begin
  Result:=CheckExist('TBL_MOVRULX',['RULX_IDEX',RULXIDEX],AUniConnection);
end;

function TMovRulX.GetNextIdex: Integer;
begin

end;

function TMovRulX.GetNextIdex(AUniConnection: TUniConnection): Integer;
begin

end;

function TMovRulX.GetStrDelete: string;
begin
  Result:='DELETE FROM TBL_MOVRULX WHERE   RULX_IDEX=:RULX_IDEX';
end;

function TMovRulX.GetStrInsert: string;
begin
  Result:='INSERT INTO TBL_MOVRULX'
         +'    ( RULX_IDEX, RULX_TEXT)'
         +'    VALUES'
         +'    (:RULX_IDEX,:RULX_TEXT)';
end;

function TMovRulX.GetStrsIndex: string;
begin
  Result:=Format('%D',[RULXIDEX]);
end;

function TMovRulX.GetStrUpdate: string;
begin
  Result:='UPDATE  TBL_MOVRULX SET'
         +'    RULX_TEXT=:RULX_TEXT'
         +'    WHERE RULX_IDEX=:RULX_IDEX';
end;

constructor TMovRulX.Create;
begin

end;

destructor TMovRulX.Destroy;
begin

  inherited;
end;

class function TMovRulX.ReadDS(AUniQuery: TUniQuery): TUniEngine;
begin
  Result:=TMovRulX.Create;
  with TMovRulX(Result) do
  begin
    RULXIDEX:=AUniQuery.FieldByName('RULX_IDEX').AsInteger;
    RULXTEXT:=AUniQuery.FieldByName('RULX_TEXT').AsString;
  end;  
end;

class function  TMovRulX.CopyIt(AMovRulX: TMovRulX): TMovRulX;
begin
  Result:=TMovRulX.Create;
  Result.RULXIDEX:=AMovRulX.RULXIDEX;
  Result.RULXTEXT:=AMovRulX.RULXTEXT;
end;

class procedure TMovRulX.CopyIt(AMovRulX:TMovRulX;var Result:TMovRulX);
begin
  if Result=nil then Exit;
  Result.RULXIDEX:=AMovRulX.RULXIDEX;
  Result.RULXTEXT:=AMovRulX.RULXTEXT;
end;

end.

